﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Peak.Web.Controllers
{
  public class ChartDataResult  :ActionResult
  {
    private readonly OpenFlashChart.OpenFlashChart _chart;

    public ChartDataResult(OpenFlashChart.OpenFlashChart chart)
    {
      _chart = chart;
    }

    public override void ExecuteResult(ControllerContext context)
    {
      context.HttpContext.Response.Buffer = true;
      context.HttpContext.Response.Clear();
      context.HttpContext.Response.CacheControl = "no-cache";
      context.HttpContext.Response.Write(_chart.ToPrettyString());
      context.HttpContext.Response.End();
    }
  }
}
